home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / err_func.arc / ERR_FUNC.PAS next >
Pascal/Delphi Source File  |  1990-09-16  |  23KB  |  626 lines

  1. {$O+,F+}
  2. Unit Err_Func;
  3.  
  4. INTERFACE
  5.  
  6. Uses CRT,DOS;
  7.  
  8.  
  9. VAR
  10.     Exit_Msg : String;
  11.     Old_Exit : Pointer;
  12.     InitSP : Word;
  13.  
  14. IMPLEMENTATION
  15. Type
  16.     Q_ptr = ^Q_Data;
  17.     Q_Data = record
  18.                       Next : Q_Ptr;
  19.                       Line_to_display : byte;
  20.                       Err_Address : pointer;
  21.                       Err_Seg : String[4];
  22.                       Err_Ofs : String[4];
  23.                       Err_Unit : String[30];
  24.                       Err_Line : Longint;
  25.                 end;
  26.  
  27. VAR
  28.    Stack_q : Q_ptr;
  29.    Current_Line : Q_Ptr;
  30.    Prev_Line : Q_Ptr;
  31.  
  32.   {$L STAKDUMP}        {Kim Kokkokonnen's STAKDUMP routine from the Tpro Bonus Disk}
  33.   procedure Trace;
  34.     {-Dump stack of return addresses}
  35.   external;
  36.  
  37. FUNCTION Exist(Filename:string):boolean;
  38. {returns true if file exists}
  39. VAR File_Rec: SearchRec;
  40. begin
  41.     FindFirst(Filename,AnyFile,File_Rec);
  42.     Exist := (DOSError = 0);
  43. end;  {Func Exist}
  44.  
  45. FUNCTION Strip_Blank(S : String) : String;
  46. VAR Lng : byte ABSOLUTE S;
  47. begin
  48.      {Strip Blanks before Source string}
  49.      While S[1] = ' ' do
  50.            Delete(S,1,1);
  51.      {Strip Blanks After Source string}
  52.      While S[lng] = ' ' do
  53.            Delete(S,lng,1);
  54.      Strip_Blank := S;
  55. end;
  56.  
  57. FUNCTION Str2Int(S : String) :Integer;
  58. VAR I,E : integer;
  59. begin
  60.      Val(S,I,E);
  61.      Str2Int := I;
  62. end;
  63.  
  64. FUNCTION Int2Str(I : Integer) :String;
  65. VAR S : String;
  66. begin
  67.      Str(I,S);
  68.      Int2Str := S;
  69. end;
  70.  
  71. FUNCTION Hex(w : Word) : STRING;
  72. const
  73.   hexChars : array [0..$F] of Char =
  74.     '0123456789ABCDEF';
  75. begin
  76.   hEX :=hexChars[Hi(w) shr 4]+hexChars[Hi(w) and $F]+
  77.     hexChars[Lo(w) shr 4]+hexChars[Lo(w) and $F];
  78. END;
  79.  
  80. Function Hex_to_int(h : String) : word;
  81. const
  82.   hexChars : String[16] = '0123456789ABCDEF';
  83. var f : word;
  84. begin
  85.      f := 0;
  86.      while length(h) > 0 do
  87.      begin
  88.           if pos(Copy(h,1,1),HexChars) = 0 then
  89.               f := 0
  90.           Else
  91.               f := (f*16)+pos(H[1],Hexchars)-1;
  92.           delete(h,1,1);
  93.      end;
  94.      Hex_to_int := f;
  95. end;
  96.  
  97. FUNCTION SHOW_PTR(p : POINTER) : STRING;
  98. BEGIN
  99.        IF P = NIL THEN
  100.         sHOW_PTR := 'NIL'
  101.        else
  102.         SHOW_PTR := HEX(SEG(P^))+':'+HEX(OFS(P^));
  103. END;
  104.  
  105. Procedure Ext_Error(Var ex_code ,Class , Action, Locus : byte);
  106. var
  107.   Regs : Registers;
  108. begin
  109.   Regs.AH := $59;
  110.   Regs.BX := 00;
  111.   MsDos(Regs);
  112.   Ex_code := Regs.AX;
  113.   Class := Regs.BH;
  114.   Action := Regs.BL;
  115.   Locus := Regs.CH;
  116. end;  { Ext_Error }
  117.  
  118. Function  Ptr_Between(Test,Min,Max : pointer) : Boolean;
  119. var
  120.      Ptr_addr ,
  121.      top_addr,
  122.      bott_addr,
  123.      temp_addr : longint;
  124. begin
  125.      Ptr_addr := seg(Test^);
  126.      Ptr_addr := (ptr_addr*16);
  127.      Ptr_addr := ptr_addr+ofs(Test^);
  128.      top_addr := seg(Max^);
  129.      top_addr := (top_addr*16);
  130.      top_addr := top_addr+ofs(Max^);
  131.      bott_addr := seg(min^);
  132.      bott_addr:=(bott_addr*16);
  133.      bott_addr:=bott_addr+ofs(min^);
  134.      if Bott_addr > top_addr then
  135.      begin
  136.           temp_addr := bott_addr;
  137.           bott_addr := top_addr;
  138.           Top_addr := temp_addr;
  139.      end;
  140.      Ptr_Between := (Ptr_addr >= bott_addr) AND (Ptr_addr < top_addr);
  141. end;
  142.  
  143. Procedure Insert_to_Queue(_Line : Byte; _Error_seg, _Error_ofs : word);
  144. VAR Temp_Line : Q_Ptr;
  145.     Temp_addr : longint;
  146. begin
  147.      {Insert Line, and err_address to Q, blank Data}
  148.      New(Temp_Line);
  149.      Fillchar(Temp_Line^,Sizeof(Temp_Line^),0);
  150.      Temp_Line^.Line_to_Display := _Line;
  151.      Temp_Line^.Err_Address := ptr(_Error_seg,_Error_Ofs);
  152.      Temp_Line^.err_seg := Hex(_Error_seg);
  153.      Temp_Line^.err_ofs := Hex(_Error_ofs);
  154.      Current_Line := Stack_Q^.next;
  155.      Prev_Line := Stack_Q;
  156.      While (Current_Line <> Stack_Q)
  157.        AND (seg(Current_Line^.Err_Address^) < _ERROR_seg)
  158.        AND (ofs(Current_Line^.Err_Address^) < _ERROR_ofs) do
  159.      begin
  160.           Prev_Line := Current_Line;
  161.           Current_Line := Current_Line^.next;
  162.      end;
  163.      Prev_Line^.next := temp_Line;
  164.      Temp_Line^.next := Current_Line;
  165. end;
  166.  
  167.  
  168. Procedure Print_Q_Data;
  169. VAR
  170.   Map_File : TEXT;
  171.   Map_Name : PathStr;
  172.   Map_Dir  : dirStr;
  173.   MAP_FlNm : NameStr;
  174.   MAP_Ext  : ExtStr;
  175.   Map_Line : String;
  176.   Text_Buff : pointer;
  177.   Text_Sze : longint;
  178.   Valid_Map : Boolean;
  179.   Line_Col : Byte;
  180.   old_t,
  181.   T_Line,
  182.   Count_t : Byte;
  183.   Suspect_Unit : NameStr;
  184.   Suspect_Line : Integer;
  185.   Suspect_Seg ,
  186.   Suspect_Ofs : Longint;
  187.   found_Here : boolean;
  188.  
  189. begin
  190.      {Going through Q fill in Details as you come to them}
  191.      {Open MAP file at Paramstr[0]'s path}
  192.  
  193.      Textcolor(lightgreen);
  194.      Old_T := wherey;
  195.      fsplit(Fexpand(Paramstr(0)),Map_dir,Map_FlNm,Map_Ext);
  196.      Map_Name := Map_Dir+Map_FLNm+'.MAP';
  197.      IF NOT(EXIST(Map_Name)) then
  198.      begin
  199.            Writeln('No MAP file found at '+Map_Name);
  200.            Writeln;
  201.            Valid_Map := False;
  202.      end
  203.      ELSE
  204.      begin
  205.            Valid_Map := True;
  206.            {Open Map File}
  207.            ASSIGN(Map_File,Map_Name);
  208.            Text_Sze := Maxavail - 2048;
  209.            if Text_Sze > 65520 then
  210.               Text_Sze := 65520;
  211.            If Text_Sze > 1024 then
  212.            begin
  213.                 getmem(Text_Buff,Text_Sze);
  214.                 SetTextBuf(Map_File,Text_Buff^,Text_Sze);
  215.            end;
  216.            Reset(Map_File);
  217.            MAP_Line := '';
  218.            {Read lines until eof or _Start__Stop}
  219.            TextColor(lightblue);
  220.            While (copy(MAP_Line,1,12) <> ' Start  Stop') and not(eof(Map_File)) do
  221.            begin
  222.                 Readln(Map_File,Map_Line);
  223.            end;
  224.            IF EOF(Map_File) then
  225.            begin
  226.                 Writeln;
  227.                 Writeln('Can''t Find Segments in Map File '+Map_Name);
  228.                 Valid_Map := False;
  229.            end
  230.      end;
  231.      found_here := false;
  232.      If Valid_Map then
  233.      begin
  234.            {Reset the list}
  235.            Current_Line := Stack_Q^.next;
  236.  
  237.            {First go thru Segment info fillin the list}
  238.            Readln(Map_File,Map_Line);
  239.            Readln(Map_File,Map_Line);
  240.            {Read Lines until EOF or not CODE}
  241.            Write('Reading '+Map_Name+' for SEGMENT Info :');
  242.            While Not(EOF(MAP_File))
  243.              and (Map_Line <> '')
  244.              and (Current_Line <> Stack_Q) do
  245.            begin
  246.                found_here := false;
  247.                if random(2) = 1 then Write('.');
  248.                {Check if 2-4 = Int-hex Error Addr}
  249.                If copy(Map_Line,2,4) > Current_Line^.err_seg then
  250.                begin
  251.                     {This is it}
  252.                     Current_Line^.Err_Unit := 'Unknown (No Segment Data)';
  253.                     Current_line := Current_Line^.next;
  254.                end;
  255.                If copy(Map_Line,2,4) = Current_Line^.err_seg then
  256.                begin
  257.                     {This is it}
  258.                     Current_Line^.Err_Unit := strip_Blank(copy(Map_Line,23,18));
  259.                     Current_line := Current_Line^.next;
  260.                     found_here := true;
  261.                end;
  262.                if not Found_here then
  263.                     Readln(Map_File,Map_Line);
  264.           end;
  265.           While Current_Line <> Stack_q do
  266.           begin
  267.                Current_Line^.Err_Unit := 'Unknown (No Segment Data)';
  268.                Current_Line := Current_Line^.next;
  269.           end;
  270.  
  271.           {Skip publics info}
  272.           Writeln;
  273.           {Loop through until LINE}
  274.           While (not(EOF(Map_File)) AND
  275.                 (copy(Map_Line,1,4) <> 'Line')) do
  276.           begin
  277.                Readln(Map_File,Map_Line);
  278.           end;
  279.           If eof(Map_File) then
  280.           begin
  281.                Writeln;
  282.                Writeln('Program was not compiled with Line number info');
  283.           end;
  284.           Current_Line := Stack_Q^.next;
  285.           {Go through Line number info}
  286.           Write('Reading '+Map_Name+' for LINE Info :');
  287.           {Search for err_seg:_err_Ofs in each of the four possitions}
  288.  
  289.           While (not(EOF(Map_File))
  290.             AND (Current_Line <> Stack_Q)) do
  291.           begin
  292.                if random(20) = 1 then Write('.');
  293.                For Line_Col := 0 to 3 do
  294.                begin
  295.                      found_here := True;
  296.                      while Found_here do
  297.                      begin
  298.                           found_here := False;
  299.                           if copy(map_line,12,1) <> ':' then
  300.                                Suspect_Seg := -1
  301.                           Else
  302.                           begin
  303.                                Suspect_Seg := Hex_to_int(copy(Map_Line,(Line_Col*16)+8,4));
  304.                                Suspect_Ofs := Hex_to_int(copy(Map_Line,(Line_Col*16)+13,4));
  305.                           end;
  306.                           if Suspect_seg > seg(Current_Line^.Err_Address^) then
  307.                           begin
  308.                                Current_Line^.Err_Line := 0;
  309.                                Current_Line := Current_Line^.next;
  310.                           end;
  311.                           if Suspect_seg = seg(Current_Line^.Err_Address^) then
  312.                           begin
  313.                                IF (copy(Map_Line,(Line_Col*16)+13,4) >= Current_Line^.Err_Ofs) THEN
  314.                                begin
  315.                                     Current_Line^.Err_Line := Str2int(strip_Blank(copy(Map_line,line_col*16+1,6)));
  316.                                     Current_Line := Current_Line^.next;
  317.                                     found_here := true;
  318.                                end;
  319.                           end;
  320.                      end;
  321.                end;
  322.                if Not found_here then
  323.                   Readln(Map_File,Map_Line);
  324.           end;
  325.           While Current_Line <> Stack_Q do
  326.           begin
  327.                Current_Line^.Err_Line := 0;
  328.                Current_line := Current_Line^.next;
  329.           end;
  330.      end;{Valid_Map}
  331.      {Close Map}
  332.      Close(Map_File);
  333.      If Text_Sze > 1024 then
  334.      begin
  335.           freemem(Text_Buff,Text_Sze);
  336.      end;
  337.      t_Line := wherey;
  338.      for count_t := Old_T to t_Line do
  339.      begin
  340.           GotoXY(1,Count_t);
  341.           Clreol;
  342.      end;
  343.      Gotoxy(1,old_t);
  344.      {Then Print out Q data}
  345.      Current_Line := Stack_Q^.next;
  346.      While Current_Line <> Stack_Q do
  347.      begin
  348.           GotoXY(15,Current_Line^.Line_to_Display);
  349.           with Current_Line^ do
  350.           begin
  351.                if Err_Line = 0 then
  352.                    Write('Location :'+strip_Blank(err_Unit)+'  No Line Data')
  353.                Else
  354.                    Write('Location :'+strip_Blank(err_Unit)+'  On or just before Line:'+int2str(err_Line));
  355.           end;
  356.           Current_Line := current_Line^.next;
  357.      end;
  358. end;
  359.  
  360. {$F+}
  361.  
  362. Procedure Exit_Message;
  363.  
  364. type    Spot   = record
  365.             case boolean of
  366.                 0 : (Character : Char;
  367.                      Attribute : Byte);
  368.                 1 : (Pair      : word);
  369.          end;
  370.     Screen = array[1..25,0..79] of Spot;
  371.  
  372. VAR
  373.   Dos_Err,E,c,a,l : byte;
  374.   blank : integer;
  375.   err_s : string;
  376.   Old_T,
  377.   count_t : Byte;
  378.   T_Line : Byte;
  379.   TPas_Err : String;
  380.   Max_Line : word;
  381.   found_max : Boolean;
  382.   Text0 : screen absolute $B800:$0000;
  383.   T_1,
  384.   T_2 : word;
  385.   Output_File : TEXT;
  386.  
  387. begin
  388.      textmode(3);
  389.      Exitproc := old_Exit;
  390.      TextColor(Yellow);
  391.      if (ErrorAddr <> nil) and (Mem[PrefixSeg:5] <> $C3) then
  392.      begin
  393.           {Error not previously handled, and not in user-interface Turbo}
  394.           {Reset output to CRT, to give some pretty colours}
  395.  
  396.           AssignCrt(Output);
  397.           Rewrite(Output);
  398.  
  399.           {STRONGARM SOME HEAP SPACE, If other error functions need heap
  400.           memory make sure they are activated first, ie: Initialised later
  401.           in the program, CONFUSED? Sorry just take my word for it :-}
  402.  
  403.           RELEASE(HeapOrg);
  404.  
  405.           {Firstly find out the Turbo Pascal error name}
  406.  
  407.           Case ExitCode of
  408.                 1: TPas_Err := 'Invalid DOS function code';
  409.                 2: TPas_Err := 'File not found';
  410.                 3: TPas_Err := 'Path not found';
  411.                 4: TPas_Err := 'Too many open files';
  412.                 5: TPas_Err := 'File access denied';
  413.                 6: TPas_Err := 'Invalid file handle';
  414.                 8: TPas_Err := 'Not enough memory';
  415.                12: TPas_Err := 'Invalid file access code';
  416.                15: TPas_Err := 'Invalid drive number';
  417.                16: TPas_Err := 'Cannot remove current directory';
  418.                17: TPas_Err := 'Cannot rename across drives';
  419.               100: TPas_Err := 'Disk read error';
  420.               101: TPas_Err := 'Disk write error';
  421.               102: TPas_Err := 'File not assigned';
  422.               103: TPas_Err := 'File not open';
  423.               104: TPas_Err := 'File not open for input';
  424.               105: TPas_Err := 'File not open for output';
  425.               106: TPas_Err := 'Invalid numeric format';
  426.               150: TPas_Err := 'Disk is write-protected';
  427.               151: TPas_Err := 'Unknown unit';
  428.               152: TPas_Err := 'Drive not ready';
  429.               153: TPas_Err := 'Unknown command';
  430.               154: TPas_Err := 'CRC error in data';
  431.               155: TPas_Err := 'Bad Drive request structure length';
  432.               156: TPas_Err := 'Disk seek error';
  433.               157: TPas_Err := 'Unknown media type';
  434.               158: TPas_Err := 'Sector not found';
  435.               159: TPas_Err := 'Printer out of Paper';
  436.               160: TPas_Err := 'Device write fault';
  437.               161: TPas_Err := 'Device read fault';
  438.               162: TPas_Err := 'Hardware failure';
  439.               200: TPas_Err := 'Division by zero';
  440.               201: TPas_Err := 'Range check error';
  441.               202: TPas_Err := 'Stack overflow error';
  442.               203: TPas_Err := 'Heap overflow error';
  443.               204: TPas_Err := 'Invalid pointer operation';
  444.               205: TPas_Err := 'Floating point overflow';
  445.               206: TPas_Err := 'Floating point underflow';
  446.               207: TPas_Err := 'Invalid floating point operation';
  447.               208: TPas_Err := 'Overlay manager not installed';
  448.               209: TPas_Err := 'Overlay file read error';
  449.               ELSE TPas_Err := 'Unknown Error code';
  450.           end;
  451.           {Put out the standard Turbo Run-Time Error message}
  452.  
  453.           Writeln('Run-Time Error ['+int2str(exitcode)+'] '+TPas_Err+'  at  '+Show_ptr(ErrorAddr));
  454.           Textcolor(White);
  455.  
  456.           {Put out any special application warning}
  457.           Writeln('Special routine exit message: ',Exit_Msg);
  458.           Writeln;
  459.           {Find the extended error code}
  460.           Ext_Error(e ,C , A, L);
  461.           Dos_Err := DosError;
  462.           If Dos_Err <> 0 then
  463.           begin
  464.                Textcolor(LightCyan);
  465.                Writeln('DOS Extended error report shows:');
  466.                Case E of
  467.                  1 : Err_S := 'Invalid function number';
  468.                  2 : Err_S := 'File not found';
  469.                  3 : Err_S := 'Path not found';
  470.                  4 : Err_S := 'Too many open files (no handles left)';
  471.                  5 : Err_S := 'Access denied (file was opened Read Only)';
  472.                  6 : Err_S := 'Invalid handle';
  473.                  7 : Err_S := 'Memory control blocks destroyed';
  474.                  8 : Err_S := 'Insufficient memory';
  475.                  9 : Err_S := 'Invalid memory block address';
  476.                 10 : Err_S := 'Invalid environment';
  477.                 11 : Err_S := 'Invalid format';
  478.                 12 : Err_S := 'Invalid access code';
  479.                 13 : Err_S := 'Invalid data';
  480.                 15 : Err_S := 'Invalid drive was specified';
  481.                 16 : Err_S := 'Attempt to remove current directory';
  482.                 17 : Err_S := 'Not same device';
  483.                 18 : Err_S := 'No more files';
  484.                 19 : Err_S := 'Attempt to write on write-protected diskette';
  485.                 20 : Err_S := 'Unknown unit';
  486.                 21 : Err_S := 'Drive not ready';
  487.                 22 : Err_S := 'Unknown command';
  488.                 23 : Err_S := 'Data error (CRC)';
  489.                 24 : Err_S := 'Bad request structure length';
  490.                 25 : Err_S := 'Seek error';
  491.                 26 : Err_S := 'Unknown media type';
  492.                 27 : Err_S := 'Sector not found';
  493.                 28 : Err_S := 'Printer out of paper';
  494.                 29 : Err_S := 'Write fault';
  495.                 30 : Err_S := 'Read fault';
  496.                 31 : Err_S := 'General failure';
  497.                 32 : Err_S := 'Sharing violation';
  498.                 33 : Err_S := 'Lock violation';
  499.                 34 : Err_S := 'Invalid disk change';
  500.                 35 : Err_S := 'FCB unavailable';
  501.                 36 : Err_S := 'Sharing buffer overflow';
  502.                 50 : Err_S := 'Network request not supported';
  503.                 51 : Err_S := 'Remote computer not listening';
  504.                 52 : Err_S := 'Duplicate name on network';
  505.                 53 : Err_S := 'Network name not found';
  506.                 54 : Err_S := 'Network busy';
  507.                 55 : Err_S := 'Network device no longer exists';
  508.                 56 : Err_S := 'Net BIOS command limit exceeded';
  509.                 57 : Err_S := 'Network adapter hardware error';
  510.                 58 : Err_S := 'Incorrect response from network';
  511.                 59 : Err_S := 'Unexpected network error';
  512.                 60 : Err_S := 'Incompatible remote adapter';
  513.                 61 : Err_S := 'Print queue full';
  514.                 62 : Err_S := 'Not enough space for print file';
  515.                 63 : Err_S := 'Print file was deleted';
  516.                 65 : Err_S := 'Access denied';
  517.                 66 : Err_S := 'Network device type incorrect';
  518.                 67 : Err_S := 'Network name not found';
  519.                 68 : Err_S := 'Network name limit exceeded';
  520.                 69 : Err_S := 'Net BIOS session limit exceeded';
  521.                 70 : Err_S := 'Temporarily paused';
  522.                 71 : Err_S := 'Network request not accepted';
  523.                 72 : Err_S := 'Print or disk redirection is paused';
  524.                 80 : Err_S := 'File exists';
  525.                 82 : Err_S := 'Cannot make directory entry';
  526.                 83 : Err_S := 'Fail on INT 24';
  527.                 84 : Err_S := 'Too many redirections';
  528.                 85 : Err_S := 'Duplicate redirection';
  529.                 86 : Err_S := 'Invalid password';
  530.                 87 : Err_S := 'Invalid parameter';
  531.                 88 : Err_S := 'Network device fault';
  532.                end;
  533.                Writeln('Extended Error Code:',err_s);
  534.                Case c of
  535.                  1 : Err_S := 'Out of resource';
  536.                  2 : Err_S := 'Temporary situation';
  537.                  3 : Err_S := 'Permission problem';
  538.                  4 : Err_S := 'Internal error in system software';
  539.                  5 : Err_S := 'Hardware failure';
  540.                  6 : Err_S := 'Serious failure of system software';
  541.                  7 : Err_S := 'Application program error';
  542.                  8 : Err_S := 'File/item not found';
  543.                  9 : Err_S := 'File/item of invalid format or type';
  544.                 10 : Err_S := 'File/item interlocked';
  545.                 11 : Err_S := 'Media failure: wrong disk, CRC error...';
  546.                 12 : Err_S := 'Collision with existing item';
  547.                 13 : Err_S := 'Classification doesn''t exist or is inappropriate';
  548.                end;
  549.                Writeln('Error Class        :',err_s);
  550.                Case a of
  551.                  1 : Err_S := 'Retry';
  552.                  2 : Err_S := 'Retry after pause';
  553.                  3 : Err_S := 'Ask user to re-enter input';
  554.                  4 : Err_S := 'Abort program with cleanup';
  555.                  5 : Err_S := 'Abort immediately, skip cleanup';
  556.                  6 : Err_S := 'Ignore';
  557.                  7 : Err_S := 'Retry after user intervention';
  558.                end;
  559.                Writeln('Recommended Action :',err_s);
  560.                Case l of
  561.                  1 : Err_S := 'Unknown or inappropriate';
  562.                  2 : Err_S := 'Related to disk storage';
  563.                  3 : Err_S := 'Related to the network';
  564.                  4 : Err_S := 'Serial device';
  565.                  5 : Err_S := 'Memory';
  566.                end;
  567.                Writeln('Error Locus        :',err_s);
  568.                Writeln('');
  569.           end;
  570.           Writeln('Trace into Procedure Stack Shows:');
  571.           {Trace from error address to top of stack}
  572.           Trace;  {With many thanks to Kim Kokonnen for this routine}
  573.           Writeln;
  574.           Old_T := Wherey;
  575.           T_Line := wherey-2;
  576.           new(Stack_Q);
  577.           Stack_Q^.next := Stack_Q;
  578.           While (T_Line > 1) AND (Text0[T_Line,0].Character<>'T') do
  579.           begin
  580.                {From Cursor Position Grab each Trace pointer and find it's Map}
  581.                T_1 :=hex_to_int(Text0[T_Line,0].Character+
  582.                                 Text0[T_Line,1].Character+
  583.                                 Text0[T_Line,2].Character+
  584.                                 Text0[T_Line,3].Character);
  585.                T_2:=hex_to_int(Text0[T_Line,5].Character+
  586.                                 Text0[T_Line,6].Character+
  587.                                 Text0[T_Line,7].Character+
  588.                                 Text0[T_Line,8].Character);
  589.                Insert_to_Queue(T_Line, T_1 , T_2);
  590.                {Go up list putting pointer data into insertion sorted Queue}
  591.                dec(T_Line);
  592.           end;
  593.           Print_Q_Data;    {Now add info to those stack positions}
  594.           GotoXY(1,Old_t);
  595.           {Show All Error Data}
  596.           {Stop remaining handlers from reporting error}
  597.           ErrorAddr := nil;
  598.           Textcolor(lightgray);
  599.           writeln('Press any key to continue');
  600.           while not keypressed do;
  601.      end
  602.      ELSE
  603.      begin
  604.         {You used HALT(X) to get out}
  605.         if exitcode <> 0 then
  606.         begin
  607.            Writeln('Application Exit Code :'+Int2str(Exitcode));
  608.            Writeln('Routine exit message:',Exit_Msg);
  609.         end;
  610.      end;
  611. end;
  612. {$F-}
  613.  
  614.  
  615. begin
  616.         {Save initial stack pointer}
  617.         InitSP := SPtr+4;
  618.         {Set up ExitProc}
  619.         Exit_Msg := '';
  620.         Old_Exit := exitProc;
  621.         Exitproc := @Exit_Message;
  622. end.
  623.  
  624.  
  625.  
  626.